package com.ssx.mapper;

import com.ssx.entity.Role;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ssx
 * @since 2020-10-24
 */
public interface RoleMapper extends BaseMapper<Role> {

    @Select("SELECT roleName FROM role \n" +
            "LEFT JOIN employees ON role.roleId=employees.roleId\n" +
            "WHERE username=#{username}")
    public Set<String> getRoleNameByUsername(String username);

    @Select("SELECT permission FROM role \n" +
            "LEFT JOIN employees ON role.roleId=employees.roleId\n" +
            "LEFT JOIN rolepermission on role.roleId=rolepermission.roleId\n" +
            "WHERE username=#{username}")
    Set<String> getPermissonByUsername(String username);
}
